package com.dao.impl;
import java.sql.*;
import com.dao.UserDao;
import com.entity.User;

public class UserJdbcDaoImpl extends BaseJdbcDAO implements UserDao{

	public User findByName(String uname) {
		 User user=null;
		 getConn();
		 String sql="select * from user where uname=?";
		 try{
			 pstmt=conn.prepareStatement(sql);
			 pstmt.setString(1, uname);
			 rs=pstmt.executeQuery();
			 if(rs.next()){
				 user=new User();
				 user.setUid(rs.getInt("uid"));
				 user.setUname(uname);
				 user.setUpass(rs.getString("upass"));
				 }
		 }catch(SQLException e){
			 e.printStackTrace();
		 }finally{
			 closeAll();
		 }
		return user;
	}

}
